package org.testing;

import java.util.LinkedList;
import java.util.List;

import org.testing.model.correctQuestionAnswers.CorrectMultiAnswer;
import org.testing.model.correctQuestionAnswers.CorrectRangeAnswer;
import org.testing.model.correctQuestionAnswers.CorrectSingleAnswer;
import org.testing.model.correctQuestionAnswers.CorrectYesNoAnswer;
import org.testing.model.questions.MultiAnswerQuestion;
import org.testing.model.questions.Question;
import org.testing.model.questions.RangeAnswerQuestion;
import org.testing.model.questions.SingleAnswerQuestion;
import org.testing.model.questions.YesNoQuestion;
import org.testing.model.variants.SimpleLineFormatedVariant;


public class QuestionsMaker {
	List<Question> questions = new LinkedList<Question>();
	
	public QuestionsMaker() {
		Question question;
		
		question = new RangeAnswerQuestion("How many primitives in java?", new CorrectRangeAnswer(7, 9));
		questions.add(question);
		
		question = new MultiAnswerQuestion("Which are reserved words in the Java? ", new CorrectMultiAnswer(new String[]{"3", "5"}));
		question.addVariant(new SimpleLineFormatedVariant("method"));
		question.addVariant(new SimpleLineFormatedVariant("array"));
		question.addVariant(new SimpleLineFormatedVariant("native"));
		question.addVariant(new SimpleLineFormatedVariant("reference"));
		question.addVariant(new SimpleLineFormatedVariant("static"));
		questions.add(question);
		
		question = new YesNoQuestion("Is everything in Java is an object?", new CorrectYesNoAnswer("no"));
		questions.add(question);
		
		question = new SingleAnswerQuestion("The java.uti.List is a?", new CorrectSingleAnswer("3"));
		question.addVariant(new SimpleLineFormatedVariant("Class"));
		question.addVariant(new SimpleLineFormatedVariant("Abstract Class"));
		question.addVariant(new SimpleLineFormatedVariant("Interface"));
		questions.add(question); 
		
		question = new YesNoQuestion("Is it correct: int [] myList = {\"1\", \"2\", \"3\"};", new CorrectYesNoAnswer("no"));
		questions.add(question);	
		
		
		question = new MultiAnswerQuestion("Which option(s) describe the correct default values for array elements of the types indicated?", new CorrectMultiAnswer(new String[]{"1", "4"}));
		question.addVariant(new SimpleLineFormatedVariant("char -> '\u0000'"));
		question.addVariant(new SimpleLineFormatedVariant("boolean -> true"));
		question.addVariant(new SimpleLineFormatedVariant("String -> \"null\""));
		question.addVariant(new SimpleLineFormatedVariant("int -> 0"));
		question.addVariant(new SimpleLineFormatedVariant("float -> 0"));
		questions.add(question);
		
		question = new YesNoQuestion("Is it correct: int myList [] = {4, 3, 7};", new CorrectYesNoAnswer("yes"));
		questions.add(question);

		question = new SingleAnswerQuestion("Which one of the following will declare an array and initialize it with five numbers?", new CorrectSingleAnswer("2"));
		question.addVariant(new SimpleLineFormatedVariant("Array a = new Array(5);"));
		question.addVariant(new SimpleLineFormatedVariant("int [] a = {23,22,21,20,19};"));
		question.addVariant(new SimpleLineFormatedVariant("int a [] = new int[5];"));
		question.addVariant(new SimpleLineFormatedVariant("int [5] array;"));
		questions.add(question); 
		
		question = new SingleAnswerQuestion("Which is the valid declarations within an interface definition?", new CorrectSingleAnswer("1"));
		question.addVariant(new SimpleLineFormatedVariant("public double methoda();"));
		question.addVariant(new SimpleLineFormatedVariant("public final double methoda();"));
		question.addVariant(new SimpleLineFormatedVariant("static void methoda(double d1);"));
		question.addVariant(new SimpleLineFormatedVariant("protected void methoda(double d1);"));
		questions.add(question); 
		
		question = new MultiAnswerQuestion("Which three are valid declarations of a float?", new CorrectMultiAnswer(new String[]{"3", "4", "6"}));
		question.addVariant(new SimpleLineFormatedVariant("float f1 = 3.14;"));
		question.addVariant(new SimpleLineFormatedVariant("float f2 = 2001.0D;"));
		question.addVariant(new SimpleLineFormatedVariant("float f3 = 2.81F;"));
		question.addVariant(new SimpleLineFormatedVariant("float f4 = -343;"));
		question.addVariant(new SimpleLineFormatedVariant("float f5 = 42e7;"));
		question.addVariant(new SimpleLineFormatedVariant("float f6 = 0x12345;"));
		questions.add(question);
		
		question = new YesNoQuestion(" Is the numerical range of a char 0 to 32767", new CorrectYesNoAnswer("no"));
		questions.add(question);	
	}
	
	public List<Question> getQuestionsForTest(int numberRequestedQuestions) {
		List<Question> questionsForOutput = new LinkedList<Question>();
		for(int quest = 0; quest < numberRequestedQuestions; quest++) {
			questionsForOutput.add(questions.get(quest));
		}
		return questionsForOutput;
	}

}
